// This file is part of OpenTSDB.
// Copyright (C) 2017 TeleDB Development Group.
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or (at your
// option) any later version.  This program is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
// General Public License for more details.  You should have received a copy
// of the GNU Lesser General Public License along with this program.  If not,
// see <http://www.gnu.org/licenses/>.
package net.opentsdb.utils.hbase;

import com.stumbleupon.async.Deferred;
import org.hbase.async.KeyValue;
import org.hbase.async.PutRequest;

import java.util.List;

public interface HbaseUtils {

    /**
     * 新增rowkey数据
     *
     * @param rowkey
     * @param families
     * @param qulitifer
     */
    void storeData(byte[] rowkey, byte[] families, byte[] qulitifer, byte[] value);

    /**
     * 删除rowkey数据
     *
     * @param rowkey
     * @param families
     * @param qulitifer
     */
    Deferred<Object> deleteData(byte[] rowkey, byte[] families, byte[] qulitifer);

    /**
     * 判断rowkey是否存在
     *
     * @param rowkey
     * @param families
     * @param qulitifer
     * @return
     */
    boolean existsData(byte[] rowkey, byte[] families, byte[] qulitifer);

    /**
     * fetch对应参数值
     *
     * @param rowkey
     * @param families
     * @param qulitifer
     * @return
     */
    List<KeyValue> fetchData(byte[] rowkey, byte[] families, byte[] qulitifer);

    /**
     * 简单cas实现
     *
     * @param expected  目标值
     * @return
     */
    boolean casStoreData(byte[] rowkey, byte[] families, byte[] qulitifer, byte[] value, byte[] expected);
}
